package consulta;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class FinalInterface extends JDialog{
	private static final long serialVersionUID = 1L;
	JFrame mainFrame;
	String[] resul;
	
	public FinalInterface(JFrame mainFrame, String[] resul){
		this.mainFrame = mainFrame;
		this.resul = resul;
		
		setTitle("Consulta Seleccionada");
		this.setResizable(false);
		principal.MainInterface.centerWindow(this, 3);
		
		this.add(getMainPanel());
	}
	
	public JPanel getMainPanel(){
		JPanel mainPanel = new JPanel();
		mainPanel.setLayout(new GridLayout(resul.length + 1,1));
		
		// Resultados
		for (String r : resul)
			mainPanel.add(new JLabel(r));
		
		// Botones
		JButton volver = new JButton("Volver");
		volver.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				FinalInterface.this.dispose();
				mainFrame.setVisible(true);
			}
		});
		mainPanel.add(volver);
		
		return mainPanel;
	}
}
